package com.xxh.workQueue;

import com.rabbitmq.client.Channel;
import com.rabbitmq.client.Connection;
import com.xxh.utils.MqUtils;

import java.io.IOException;
import java.util.concurrent.TimeoutException;

/**
 * s生产者
 */
public class Producer {
    public static void main(String[] args) throws IOException, TimeoutException {
        Connection connection = MqUtils.getConnection();
        Channel channel = connection.createChannel();
        channel.queueDeclare("testwork",false,false,false,null);
        //发布消息
        for (int i = 0; i < 20; i++) {
            channel.basicPublish("","testwork",null,("this is message "+i).getBytes());
        }
        channel.close();
        connection.close();
    }
}
